package com.studies.pc.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.studies.common.R.R;
import com.studies.pc.pojo.Activity;
import com.studies.pc.pojo.EvaluateInfo;
import com.studies.pc.pojo.UndertakeOrg;
import com.studies.pc.pojo.UndertakeOrgWithBlobs;
import com.studies.pc.service.ActivityService;
import com.studies.pc.service.UndertakeOrgService;
import com.studies.pc.vo.UndertakeOrgWithBlobsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 研学承办机构 前端控制器
 * </p>
 *
 * @author 研学活动后台
 * @since 2019-12-24
 */
@Api(tags="研学承办机构模块")
@CrossOrigin //跨域
@RestController
@RequestMapping("/pc/undertake-org")
public class UndertakeOrgController {
    @Autowired
    private UndertakeOrgService undertakeOrgService;
    @ApiOperation(value = "分页承办机构列表")
    @PostMapping(value = "qryUndertakeOrgInfoPage/{page}/{limit}")
    public R qryUndertakeOrgInfoPage(@ApiParam(name = "page", value = "当前页码", required = true)
                        @PathVariable Long page,

                        @ApiParam(name = "limit", value = "每页记录数", required = true)
                        @PathVariable Long limit,
                        @ApiParam(name = "id", value = "承办机构ID", required = false)
                            @PathVariable Integer id,
                        @ApiParam(name = "orgname", value = "承办机构名称", required = false)
                            @PathVariable String orgname
                        ){

        Page<UndertakeOrg> pageParam = new Page<UndertakeOrg>(page, limit);

        Map<String, Object> map = undertakeOrgService.qryUndertakeOrgInfoActivityPage(pageParam,id,orgname);

        return  R.ok().data(map);
    }
    @ApiOperation(value = "承办机构详情")
    @PostMapping(value = "qryUndertakeOrgInfo/{id}")
    public R qryUndertakeOrgInfo ( @ApiParam(name = "id", value = "承办机构id", required = true)
                                                           @PathVariable Integer id){
        UndertakeOrgWithBlobsVo undertakeOrgWithBlobsVo = undertakeOrgService.qryUndertakeOrgInfo(id);
        return R.ok().data("itms",undertakeOrgWithBlobsVo);
    }

    @ApiOperation(value = "基地评分")
    @PostMapping(value = "qryBaseEvaluateInfo/{id}")
    public R qryBaseEvaluateInfo(@ApiParam(name = "id", value = "基地id", required = true)
                                 @PathVariable Integer id){
        EvaluateInfo evaluateInfo = undertakeOrgService.qryUndertakeOrgEvaluateInfo(id);
        return  R.ok().data("itms",evaluateInfo);
    }
    @ApiOperation(value = "基地评分分页")
    @PostMapping(value = "qryBaseEvaluatePage/{id}")
    public R qryUndertakeOrgEvaluateInfo(@ApiParam(name = "id", value = "基地id", required = true)
                                         @PathVariable Integer id,
                                         @ApiParam(name = "nowPage", value = "当前页码", required = true)
                                         @PathVariable Long nowPage,
                                         @ApiParam(name = "pageSize", value = "每页记录数", required = true)
                                         @PathVariable Long pageSize){
        Page<EvaluateInfo> pageParam = new Page<EvaluateInfo>(nowPage, pageSize);
        Map<String, Object> map = undertakeOrgService.qryUndertakeOrgEvaluatePage(pageParam,id);
        return  R.ok().data(map);
    }

}

